package cn.zhanghu;
/* 输入使用者的姓名，调用chooseTransport方法实现使用交通工具，判断应该使用什么交通工具
 * Created by dell on 2017/8/21.
 */
public class Person {
    private final String name;

    public Person(String name){
        this.name=name;
    }

    public static void chooseTransport(Transportation t){
        t.useTransportation();
    }
    //判断应该乘坐的交通工具
    public void useTransport(double money){
        if(money>=50){
            chooseTransport(new Taxi());
        }
        if (money >= 30 && money < 50)
            chooseTransport(new Tricycle());
        if (money >= 10 && money < 30)
            chooseTransport(new Bus());
        if (money >= 0 && money < 10)
           chooseTransport(new Walk());

    }
    @Override
    public String toString(){
        return name;
    }
}
